//
//  MainSectionHeaderView.m
//  ZhiHuDaily
//
//  Created by albert on 16/8/21.
//  Copyright © 2016年 albert. All rights reserved.
//

#import "MainSectionHeaderView.h"

@interface MainSectionHeaderView ()
@property (weak, nonatomic) UILabel *dateLabel;
@end

@implementation MainSectionHeaderView

/** 类方法 初始化 */
+ (instancetype)headerViewWithTableView:(UITableView *)tableView{
    
    static NSString *mainSectionHeaderID = @"mainSectionHeader";
    
    MainSectionHeaderView *sectionHeaderView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:mainSectionHeaderID];
    if (sectionHeaderView == nil) {//缓存池中没有，自己创建
        sectionHeaderView = [[MainSectionHeaderView alloc] initWithReuseIdentifier:mainSectionHeaderID];
    }
    return sectionHeaderView;
}

- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithReuseIdentifier:reuseIdentifier]) {
        
        [self setup];
    }
    return self;
}

#pragma mark - 初始化
- (void)setup{
    
    UILabel *dateLabel = [[UILabel alloc] init];
    dateLabel.textAlignment = NSTextAlignmentCenter;
    dateLabel.textColor = [UIColor whiteColor];
    dateLabel.font = [UIFont systemFontOfSize:16];
    [self.contentView addSubview:dateLabel];
    self.dateLabel = dateLabel;
}

#pragma mark - 布局子控件
- (void)layoutSubviews{
    [super layoutSubviews];
    
    self.dateLabel.frame = CGRectMake(0, 0, self.width, self.height);
}

#pragma mark - 属性赋值
- (void)setHeaderTitle:(NSString *)headerTitle{
    _headerTitle = [headerTitle copy];
    
    self.dateLabel.text = headerTitle;
}

#pragma mark - 外部调用方法
#pragma mark - 更新皮肤
- (void)changeToNightSkin{ // 夜间
    self.contentView.backgroundColor = JKColor(60, 60, 60);
}

- (void)changeToDaySkin{ // 白天
    self.contentView.backgroundColor = JKMainColor;
}
@end
